<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>房产详情</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
    <link href="public/bootstrap/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="public/xw/css/xcConfirm.css" rel="stylesheet" type="text/css" />
    <script src="public/JQuery.1.11.3.js"></script>
    <script src="public/bootstrap/dist/js/bootstrap.js"></script>
    <script src="public/tool/jquery.placeholder.js"></script>
    <script src="public/tool/jquery.color.js"></script>
    <script src="public/xw/js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>

    <!--[if lt IE 9]>
    <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
    <script src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<script type="text/javascript">
    $(function () {
        // Invoke the plugin
        $('input, textarea').placeholder();
    });
</script>

<style type="text/css">
    .sgBtn{width: 135px; height: 35px; line-height: 35px; margin-left: 10px; margin-top: 10px; text-align: center; background-color: #0095D9; color: #FFFFFF; float: left; border-radius: 5px;}
    .xcConfirm .popBox .ttBox{
        height:50px;
    }
</style>

<?php
include 'class/MMysql.php';
$property_id='';
$property_name='';
$property_rmb='';
$property_dollar='';
$property_short_desc='';
$property_detail_desc='';
$property_imgs='';
$parameter_value1='';
$parameter_value2='';
$parameter_value3='';
$parameter_value4='';
$parameter_value5='';
$latitude='';
$longitude='';

if(isset($_GET['property_id'])){

    $property_id = $_GET['property_id'];
    if(empty($property_id)){
        $property_id=1;
    }
    $mysql = new MMysql();
    $property = $mysql
        ->where(array('property_id'=>$property_id))
        ->select('property');
    if(count($property)>0){
        $property_id=$property[0]['property_id'];
        $property_name=$property[0]['property_name'];
        $property_rmb=$property[0]['property_rmb'];
        $property_dollar=$property[0]['property_dollar'];
        $property_short_desc=$property[0]['property_short_desc'];
        $property_detail_desc=$property[0]['property_detail_desc'];
        $parameter_value1=$property[0]['parameter_value1'];
        $parameter_value2=$property[0]['parameter_value2'];
        $parameter_value3=$property[0]['parameter_value3'];
        $parameter_value4=$property[0]['parameter_value4'];
        $parameter_value5=$property[0]['parameter_value5'];
        $latitude=$property[0]['latitude'];
        $longitude=$property[0]['longitude'];
        $property_imgs=$property[0]['property_imgs'];

        $pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
        preg_match_all($pattern,$property_imgs,$match);
        if(count($match[0])>0){
            $property_imgs=$match[1];
        }
        else{
            $property_imgs="";
        }
    }
}
?>
<body onload="getMap()">

<!--引入导航条-->
<?php
include 'base/home_header.php';
?>

<style>

    .top-menu a{
        color: #2b2b2b;
    }
    .second_menu{
        background: whitesmoke;
    }
    .dingzhi{
        position: relative;
        top:80px;
        height:121px;
        background-color: rgb(202,202,202);
        display: block;
        padding-top: 25px;
        float: left;
    }
    .dingzhi .span1{
        padding-left: 121px;
        font-size: 20px;
        color: #262626;
        line-height: 35px;
        display: inline-block;;
    }
    .dingzhi .span2{
        font-size: 14px;
    }
    .bg-color-black{
        background-color: #2B2B2B;
    }
    .dingzhi button{
        width: 140px;
        color: white;
        text-align: center;
    }
    .slide{
        /*background-image: rgb('');*/
        background-color: yellow;
        height: 136px;
        width: 81px;
        /*margin-top: 100px;*/
        float: left;;
    }
    .select{
        text-align: center;
        width: 50%;
        min-width: 590px;
        float: left;
        border-right: 1px solid whitesmoke;
        margin-top: 30px;
        font-size: 16px;
        color: #333743;
        letter-spacing: 0px;
    }
    .selectnot{
        border-right: 0px solid black;
    }
    .properties{
        position: relative;
        top:30px;
        /*background-color: red;*/
    }
    .margin_left{
        margin-left: 2%;
        margin-right: 2%;
    }
    .margin_left img{
        width: 100%;
        height: 90%;
    }

    button{
        display: inline-block;
        padding: 6px 12px;
        margin-bottom: 0;
        font-size: 14px;
        font-weight: normal;
        line-height: 1.42857143;
        text-align: center;
        white-space: nowrap;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        background-image: none;
        border: 1px solid transparent;
        border-radius: 4px;
    }

    .propertyinfo{
        width: 31%;height: 382px;
        float: left;
        margin-left: 1%;
        margin-right: 1%;
        margin-top: 20px;
    }
    .propertysinfo{
        margin: 0 auto;
        width: 1180px;
        height: 300px;
        margin-top: 30px;
        position: relative;
    }
    .imgopacity{

        -moz-opacity:0.4;
        opacity:0.4;
        filter:alpha(opacity=40);
        cursor: pointer;
    }
    .imgopacitynot{
        -moz-opacity:1;
        opacity:1;
        filter:alpha(opacity=100);
        cursor: pointer;
    }
    .OverlaysBL{
        display:none;
    }
    .header-menu .logo{
        float:left;
        padding-left:120px;
        font-size: 40px;
        color: #2b2b2b;
        letter-spacing: 0px;
        text-shadow: none;
    }
</style>

<div style="position: relative;margin: 0 auto;margin-top:140px;width: 1180px;">

    <div style="float: left;width: 625px;margin-left: 30px;">

        <div style="width: 625px;height: 561px;position: relative;overflow:auto;">
            <?php
            if(count($property_imgs)>0){

                echo '<a target="_blank" href="showimg.php?src='.$property_imgs[0].'">
<img class="pic" src="'.$property_imgs[0].'" data-src-wide="'.$property_imgs[0].'" alt="BINGOO"/>
</a>';
            }
            ?>
        </div>



        <div class="smallimg" style="position:relative;width: 625px;height: 78px;margin-top: 11px;">
            <?php
            if(count($property_imgs)<=5&&count($property_imgs)>0){
                for($i=0;$i<count($property_imgs);++$i){
                    if($i==0){
                        echo  '<img class="imgopacity imgopacitynot"  src="'.$property_imgs[$i].'" style="width: 18%;height: 78px;">';
                    }
                    else{
                        echo  '<img class="imgopacity"  src="'.$property_imgs[$i].'" style="width: 18%;height: 78px;margin-left: 1.5%;">';
                    }

                }
            }
            else{
                for($i=0;$i<5;++$i){
                    if($i==0){
                        echo  '<img class="imgopacity imgopacitynot" src="'.$property_imgs[$i].'" style="width: 18%;height: 78px;">';
                    }
                    else{
                        echo  '<img class="imgopacity" src="'.$property_imgs[$i].'" style="width: 18%;height: 78px;margin-left: 1.5%;">';
                    }

                }
            }

            ?>
        </div>
        <div style="clear:both;">

        </div>
     </div>


    <div style="float: left;width: 494px;">
        <div style="position:relative;font-size: 52px;color: #3C3D41;line-height: 57px;margin-left: 50px;margin-top: 28px;">
            <span>
                <?php
                echo $property_name;
                ?>
            </span>
        </div>

        <div style="position:relative;font-size: 16px;color: #808080;margin-left: 50px;margin-top: 48px;height: 108px;">
            <?php
            echo $property_short_desc;
            ?>
        </div>

        <ul style="position: relative;margin-left: 50px;margin-top: 37px;color: #808080;height: 150px;">

            <?php
            if(!empty($parameter_value1)){
              echo  '<li>'.$parameter_value1.'</li>';
            }
            if(!empty($parameter_value2)){
                echo  '<li>'.$parameter_value2.'</li>';
            }
            if(!empty($parameter_value3)){
                echo  '<li>'.$parameter_value3.'</li>';
            }
            if(!empty($parameter_value4)){
                echo  '<li>'.$parameter_value4.'</li>';
            }
            if(!empty($parameter_value5)){
                echo  '<li>'.$parameter_value5.'</li>';
            }
            ?>
        </ul>

        <div style="position: relative;border-bottom: 1px solid #CAD3DF;;margin-left: 69px;margin-top: 58px;">

        </div>

        <div style="float: left;margin-left: 50px;margin-top: 28px;
        font-size: 34px;color: #3C3D41;height: 43px;">
            <span>￥
                <?php
                echo $property_rmb;
                ?>
            </span>
        </div>

        <div style="float: right;margin-top: 28px;
        font-size: 40px;color: #3C3D41;">

            <?php
            echo '<input type="hidden" id="property_id" value="'.$property_id.'">';
            echo '
            <button id="tolike" style="background: #4CB7C2;height:51px;width:180px;border-radius: 4px;font-size: 15px;color:#FFFFFF;letter-spacing: 0.5px;line-height: 13px; ">
               我喜欢这套房
           </button>
           ';
            ?>

        </div>
        <div style="clear: both;">

        </div>
        <div style="position: relative;margin-left: 60px;margin-top: 28px;font-size: 16px;color: #838C8E;letter-spacing: -0.04px;">
            <span>
                $<?php
                echo $property_dollar;
                ?>
            </span>
        </div>

    </div>

    <div style="clear:both;">

    </div>
</div>

<div style="position: relative;margin: 0 auto;margin-top:103px;width: 1180px;">
    <div style="text-align: center;font-size: 20px;color: #333743;">
        <span>
           地图预览
        </span>
    </div>
    <hr>
    <div style="position: relative;">
        <div id='myMap' style="position:relative;margin: 0 auto; width:1180px; height:500px;margin-top:20px;"></div>
    </div>
</div>

<div style="position: relative;margin: 0 auto;margin-top:63px;width: 1180px;">
    <div style="text-align: center;font-size: 20px;color: #333743;">
        <span>
            描述
        </span>
    </div>
    <hr>
    <div style="position: relative;">
        <?php
        echo $property_detail_desc;
        ?>
    </div>
</div>

<div class="propertysinfo">
<hr>
    <div style="position: relative;text-align: center;font-size: 16px;color: #333743;">
        <span>
            您可能也喜欢这些房
        </span>
    </div>

    <?php

       $mysql = new MMysql();
       $sql='SELECT * FROM property WHERE del_flag=0 and property_id >= (SELECT floor(RAND() * (SELECT MAX(property_id) FROM property)))
ORDER BY property_id LIMIT 3;';

      $res = $mysql->doSql($sql);

        $arraya=Array();
        foreach ($res as $u){
            //代理商
            $agentname=$mysql->where(array('agent_id'=> $u["property_agent_id"]))->select('agent');
            $u["agent"]=$agentname[0]['agent_name'];

            $pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
            preg_match_all($pattern,$u['property_imgs'],$match);
    //            print_r($match);
            if(count($match[0])>0){
                $u["property_img"]=$match[1][0];
            }
            else{
                $u["property_img"]="";
            }
            $arraya[]=$u;
        }

    for($i=0;$i<count($arraya);++$i){
        echo '<a href="property_detail.php?property_id='.$arraya[$i]['property_id'].'"><div class="propertyinfo">
         <div style="overflow: hidden;height: 90%;">
             <img src="'.$arraya[$i]['property_img'].'" >
         </div>
        <div style="float: left;">
            <span style="display: inline-block;font-size: 16px;color: #333743;">
            '.$arraya[$i]['property_name'].'
        </span>
        </div>

        <div style="float: right;">
              <span style="display: inline-block;font-size: 16px;color: #9297a3;">￥
            '.$arraya[$i]['property_rmb'].'
        </span>
        </div>
        <div style="clear:both;">

        </div>
        <div>
             <span style="display:block;font-size: 11px;color: #9297A3;">
            '.$arraya[$i]['agent'].'
        </span>
        </div>

    </div></a>';
    }
    ?>

</div>
<div style="clear: both;">

</div>


<div style="height: 100px;">

</div>

<a class="toshowimg" target="_blank"></a>
</body>

</html>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=zh-cn"></script>
<script type="text/javascript">
    var map = null;
    var searchManager = null;
    function getMap()
    {
        map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
            credentials: 'Aq4dG26RbZekJDIAZCBdNditbr2cinnV1fuSUmkrc8LeRFZpuXlFIzDtYZDQs846'
        });
        updatePushpinLocation();
        function updatePushpinLocation()
        {
            var pushpin= new Microsoft.Maps.Pushpin(map.getCenter(), null);
            map.entities.push(pushpin);
            pushpin.setLocation(new Microsoft.Maps.Location(<?php echo $latitude ?>, <?php echo  $longitude ?>));
            map.setView({center: new Microsoft.Maps.Location(<?php echo $latitude ?>, <?php echo $longitude ?>),zoom: 10 });
        }

    }
    function createSearchManager()
    {
        map.addComponent('searchManager', new Microsoft.Maps.Search.SearchManager(map));
        searchManager = map.getComponent('searchManager');
    }
    function LoadSearchModule()
    {
        Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: geocodeRequest })
    }
    function geocodeRequest()
    {
        createSearchManager();
        var where = $(".txtsreach").val();
        var userData = { name: 'Maps Test User', id: 'XYZ' };
        var request =
        {
            where: where,
            count: 5,
            bounds: map.getBounds(),
            callback: onGeocodeSuccess,
            errorCallback: onGeocodeFailed,
            userData: userData
        };
        searchManager.geocode(request);
        getlocation();
    }
    function onGeocodeSuccess(result, userData)
    {
        if (result) {
            map.entities.clear();
            var topResult = result.results && result.results[0];
            if (topResult) {
                var pushpin = new Microsoft.Maps.Pushpin(topResult.location, null);
                map.setView({ center: topResult.location, zoom: 10 });
                map.entities.push(pushpin);
            }
        }
    }
    function onGeocodeFailed(result, userData) {
        alert('Geocode failed');
    }
    function getlocation(){
        var latlon = map.getCenter();
        //console.log('Lat/Long: ' + latlon.latitude +'/' + latlon.longitude)
    }
    $("#btnsreach").click(function () {
        LoadSearchModule();
    })
</script>
<script>
    $(function(){
        $(window).scroll(function(){
            $offset = $('.placeholder').offset();//不能用自身的div，不然滚动起来会很卡
            if($(window).scrollTop()>100){
                $('.header-menu').css({
                    'position':'fixed',
                    'top':'0px',
//                    'left':$offset.left+'px',
                    'z-index':'999',
                    'margin':'auto',
                    'width':'100%',
                    'background':'whitesmoke'
                });
            }else{
                $('.header-menu').removeAttr('style');
            }
        });
    });

    $(document).ready(function(){

        var carrousel = $( ".carrousel" );

//        $( ".portrait" ).click( function(e){
//            var src = $(this).find(".pic").attr( "data-src-wide" );
////            carrousel.find("img").attr( "src", src );
////            carrousel.fadeIn( 200 );
//           ='showimg.php?src='+src;
//        });

        carrousel.find( ".close" ).click( function(e){
            carrousel.find( "img" ).attr( "src", '' );
            carrousel.fadeOut( 200 );
        } );
        /*素材家园 - www.sucaijiayuan.com*/

        $(".smallimg img").click(function () {
           $(this).siblings().removeClass('imgopacitynot');
            $(this).addClass('imgopacitynot');
//            alert();
            $(this).parent().prev().children().attr('href','showimg.php?src='+$(this).attr('src'));
            $(this).parent().prev().children().children().attr('src',$(this).attr('src'));
        });
        $("#tolike").click(function () {

            var property_id= $("#property_id").val();
            window.location.href="like_property.php?property_id="+property_id;

        })
    });
</script>